import 'package:flutter/material.dart';
import 'package:flutter3x/demo/life_cycle_demo.dart';
import 'package:flutter3x/getx_controller/life_cycle_controller.dart';
import 'package:get/get.dart';
import 'package:flutter3x/getx_controller/getx_controller.dart';

class GetXDemo extends StatelessWidget {
  const GetXDemo({super.key});

  @override
  Widget build(BuildContext context) {
    final LifeCycleController lifeCycleController =
        Get.put(LifeCycleController());
    final GetxdemoController getcontroller = Get.put(GetxdemoController());

    return Scaffold(
      body: Align(
        alignment: Alignment.center,
        child: Container(
          width: 200,
          height: 200,
          alignment: Alignment.center,
          child: Column(
            children: [
              Obx(() => Text(getcontroller.test.value)),
              ElevatedButton(
                  onPressed: () {
                    getcontroller.changeText();
                  },
                  child: const Text("按钮")),
              Obx(() => Text(lifeCycleController.hotListStr.value)),
              ElevatedButton(
                  onPressed: () {
                    Get.to(() => const LifeCycle());
                  },
                  child: const Text("跳转到生命周期")),
            ],
          ),
        ),
      ),
    );
  }
}
